package com.gpframework.common.enums;

import lombok.extern.slf4j.Slf4j;

/**
 * uni-ubi 错误异常转换枚举
 */
@Slf4j
public enum UFaceErrMsgEnum {
    /**
     * 人员信息错误
     */
    ADMIT_NOT_EXIST("admit not exist", "用户不存在"),
    PERSON_PHONE_NUMBER_FORMAT_IS_ILLEGAL("Person phone number format is illegal", "手机号格式不正确"),
    FACE_NOT_EXIST("face not exist", "人脸不存在"),
    NOT_DETECT_FACE("Not detect face", "人脸不合法"),
    THE_FACE_IS_TOO_DARK("The face is too dark", "光线不足"),
    IMAGE_FORMAT_IS_ILLEGAL("image format is illegal", "图片格式不合法"),
    PERSON_NAME_SHOULD_FORM_BY_NUMBER_CHAR_BLANK_CHINESE_CHARACTERS("Person name should form by number, char, blank, '_' and Chinese characters", "名称只支持'_'特殊字符"),
    FACE_SIMILAR_TOO_LOW("face similar too low", "人脸相似度过低"),
    PERSON_NOT_EXIST("person not exist", "人员信息不存在"),
    THE_PIXELS_OF_THE_FACE_MUST_BE_GREATER_THAN("The pixels of the face must be greater than 80.", "面部的像素必须大于80，请把人脸尽可能集中在人相框内"),
    MUST_HAVE_ONLY_ONE_FACE("must have only one face", "照片存在多张人脸"),
    PITCH_ANGLE_IS_NOT_IN_RANGE("Pitch angle is not in range", "人脸角度不正确"),
    DOWNLOAD_EXCEED("download exceed", "下载超时，请重新拍照"),
    PERSON_NAME_CANNOT_BEEN_NULL("Person name cannot been null", "人员名称不能为空"),
    /**
     * 设备错误
     */
    DEVICE_DOES_NOT_EXIST("Device does not exist", "设备不存在或存在识别记录"),
    DEVICE_NOT_ONLINE("device not online", "设备不在线"),

    /**
     * 人脸错误
     */
    FACE_IS_BEYOND_OR_NEAR_THE_EDGE_OF_THE_PICTURE("Face is beyond or near the edge of the picture", "脸在画面的边缘之外或边缘附近"),

    MORE_THAN_3_UNIT_FOR_A_ADMIT("more than 3 unit for a admit", "人脸照片不能超过3张"),
    TOKEN_IS_ILLEGAL("token is illegal", "服务繁忙，请重新"),
    ;

    private final String errMsgEN;
    private final String errMsgCN;

    public String getErrMsgEN() {
        return errMsgEN;
    }

    public String getErrMsgCN() {
        return errMsgCN;
    }

    UFaceErrMsgEnum(String errMsgEN, String errMsgCN) {
        this.errMsgEN = errMsgEN;
        this.errMsgCN = errMsgCN;
    }

    public static String getErrMsgCN(String errMsgEN) {
        log.error("uni-ubi错误信息-->【{}】", errMsgEN);
        //去除前后空格
        errMsgEN = errMsgEN.trim().trim();
        for (UFaceErrMsgEnum value : UFaceErrMsgEnum.values()) {
            if (value.getErrMsgEN().equals(errMsgEN)) {
                return value.getErrMsgCN();
            }
        }
        return errMsgEN;
    }
}
